package com.my.bld.utils;

import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import com.my.bld.model.User;



public class ExportIntentionUtils {
	@SuppressWarnings("deprecation")
	public static HSSFWorkbook ExportIntentionInfo(String title, List<User> dakas, String name) {
		String[] titles = title.substring(0, title.length()).split(",");
		HSSFWorkbook wb = new HSSFWorkbook();
		HSSFSheet sheet = wb.createSheet(name);
		HSSFRow row = sheet.createRow((int) 0);
		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		HSSFCell cell = row.createCell((short) 0);
		//"登录名,密码,手机号,真实姓名"
		for (int i = 0; i < titles.length; i++) {
			cell.setCellValue(titles[i]);
			cell.setCellStyle(style);
			cell = row.createCell((short) i + 1);
		}
		for (int i = 0; i < dakas.size(); i++) {
			row = sheet.createRow((int) i + 1);
			User daka=dakas.get(i);
			for(int j = 0; j <4 ; j++){
				if(j==0){
					row.createCell((short) j).setCellValue(daka.getUserName());
				}
				if(j==1){
					row.createCell((short) j).setCellValue(daka.getPassWord());
				}
				if(j==2){
					row.createCell((short) j).setCellValue(daka.getPhone());
				}
				if(j==3){
					row.createCell((short) j).setCellValue(daka.getRealName());
				}
			}		
		}
		return wb;
	}
}
